package com.matrix.framework.sysconfig.iplist.data;

import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

/**
 * IP访问记录数据模型
 *
 * Copyright © 海平面工作室 版权所有
 *
 * @Author: Leo
 * @Create: 2024/12/1 15:30
 * @Since 1.2
 */
@Table(name = "security_ip_access_record")
public class IpAccessRecordPo {

    @Id
    private Long id;

    private String ipAddress; // IP地址

    private String username; // 用户名（如果有）

    private String apiPath; // 访问的API路径

    private String userAgent; // 用户代理

    private String requestMethod; // 请求方法

    private Integer responseStatus; // 响应状态码

    private Long responseTime; // 响应时间（毫秒）

    private String result; // 访问结果：SUCCESS, FAILED, BLOCKED

    private String reason; // 失败或阻止原因

    private Long accessTime = System.currentTimeMillis(); // 访问时间

    private Long createTime = System.currentTimeMillis();

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getApiPath() {
        return apiPath;
    }

    public void setApiPath(String apiPath) {
        this.apiPath = apiPath;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public Integer getResponseStatus() {
        return responseStatus;
    }

    public void setResponseStatus(Integer responseStatus) {
        this.responseStatus = responseStatus;
    }

    public Long getResponseTime() {
        return responseTime;
    }

    public void setResponseTime(Long responseTime) {
        this.responseTime = responseTime;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Long getAccessTime() {
        return accessTime;
    }

    public void setAccessTime(Long accessTime) {
        this.accessTime = accessTime;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "IpAccessRecordPo{" +
                "id=" + id +
                ", ipAddress='" + ipAddress + '\'' +
                ", username='" + username + '\'' +
                ", apiPath='" + apiPath + '\'' +
                ", userAgent='" + userAgent + '\'' +
                ", requestMethod='" + requestMethod + '\'' +
                ", responseStatus=" + responseStatus +
                ", responseTime=" + responseTime +
                ", result='" + result + '\'' +
                ", reason='" + reason + '\'' +
                ", accessTime=" + accessTime +
                ", createTime=" + createTime +
                '}';
    }
}